using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace HRM.Models.Mapping
{
    public class tk_QLSuPhamMap : EntityTypeConfiguration<tk_QLSuPham>
    {
        public tk_QLSuPhamMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.MaNV)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.MaDDKy)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.MaTKQLSP)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("tk_QLSuPham");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SoLuong).HasColumnName("SoLuong");
            this.Property(t => t.HocKi).HasColumnName("HocKi");
            this.Property(t => t.MaNV).HasColumnName("MaNV");
            this.Property(t => t.MaDDKy).HasColumnName("MaDDKy");
            this.Property(t => t.MaTKQLSP).HasColumnName("MaTKQLSP");

            // Relationships
            this.HasRequired(t => t.dm_tk_QLSuPham)
                .WithMany(t => t.tk_QLSuPham)
                .HasForeignKey(d => d.MaTKQLSP);
            this.HasRequired(t => t.DotDK_TK)
                .WithMany(t => t.tk_QLSuPham)
                .HasForeignKey(d => d.MaDDKy);
            this.HasRequired(t => t.NhanVien)
                .WithMany(t => t.tk_QLSuPham)
                .HasForeignKey(d => d.MaNV);

        }
    }
}
